import axios from 'axios';

let base = '/admin';

export const requestLogin = params => { return axios.post(`${base}/login`, params).then(res => res.data); };

export const getBanner = params => { return axios.get(`${base}/banner`, { params: params }); };

export const getProduct = params => { return axios.get(`${base}/product`, { params: params }); };


export const getMenu = params => { return axios.get(`${base}/get_menu`, { params: params }); };

export const getCategory = params => { return axios.get(`${base}/category/get_category`, { params: params }); };

export const getOrder = params => { return axios.get(`${base}/order/index`, { params: params }); };

export const getUserList = params => { return axios.get(`${base}/user/index`, { params: params }); };

export const getAdminList = params => { return axios.get(`${base}/user/admin`, { params: params }); };

export const removeUser = params => { return axios.get(`${base}/user/remove`, { params: params }); };

export const batchRemoveUser = params => { return axios.get(`${base}/user/batchremove`, { params: params }); };

export const editBanner = params => { return axios.get(`${base}/banner/edit`, { params: params }); };

export const addBanner = params => { return axios.post(`${base}/banner/add`, params).then(res => res.data); };

export const removeBanner = params => { return axios.get(`${base}/banner/delete/`+ params.banner_id + ``, params).then(res => res.data); };

export const addUser = params => { return axios.get(`${base}/user/add`, { params: params }); };

export const addProduct = params => { return axios.post(`${base}/product/add`, params).then(res => res.data); };

export const editProduct = params => { return axios.post(`${base}/product/edit`, params).then(res => res.data); };

export const addCategory = params => { return axios.post(`${base}/category/add`, params).then(res => res.data); };

export const productDetail = params => { return axios.get(`${base}/product/detail/`+ params.product_id + ``, params).then(res => res.data); };

export const removeProduct = params => { return axios.get(`${base}/product/delete/`+ params.product_id + ``, params).then(res => res.data); };

export const removeFile = params => { return axios.post(`${ base}/upload/file_delete`, params).then(res => res.data); };

export const fileUpload = params => { return axios.post(`${base}/product/add`,params,{
    headers:{token:token,'Content-Type': 'multipart/form-data'}
}).then(res => res.data); };
